<% page_title "Users" %>

<%= render 'projects/header', project: @project, tab: "user_project_roles" %>

<section id="user-project-roles" class="tabs">
  <h2 class="section-subtitle">Project Level Roles</h2>

  <%= render 'user_project_roles/search_bar', system_level: false %>

  <div class="users-csv">
    <%= link_to "Download as CSV", new_csv_export_path(format: :csv, type: :users, project_id: @project.id) %>
  </div>

  <table class="table table-hover table-condensed">
    <thead>
    <tr>
      <th><%= sortable "id" %></th>
      <th><%= sortable "name" %></th>
      <th><%= sortable "email" %></th>
      <th>ROLE</th>
      <th></th>
    </tr>
    </thead>
    <tbody>
    <% if @users.length == 0 %>
      <tr>
        <td>No users found.</td>
      </tr>
    <% else %>
        <%= render partial: 'user_project_role', collection: @users, as: :user %>
    <% end %>
    </tbody>
  </table>

  <%= paginate @users %>
</section>
